import java.util.Scanner;

class MyCounter {
    public volatile int flag = 0;
}

public class Main {
    public static void main(String[] args) {
        MyCounter myCounter = new MyCounter();
        Thread t1 = new Thread(()->{
           while (myCounter.flag == 0){
               //
           }
        });

        Thread t2 = new Thread(()->{
            Scanner in = new Scanner(System.in);
            System.out.println("请输入一个整数，输入0表示继续，输入其它表示停止");
            myCounter.flag =  in.nextInt();
        });

        t1.start();
        t2.start();
    }
}
